- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1
 
Add support for dynamic symbols when DYNAMIC segment is missing #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 12.9.2-dd
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enables parsing of dynamic symbols and their string table from section headers when the PT_DYNAMIC segment is absent, falling back to PT_DYNAMIC only if needed.
- Initialize 
dynsymsanddynstrtabearlier to a known default state - Add parsing of 
.dynsym/.dynstrviaSHT_DYNSYMsection - Introduce fallback logic: use DYNAMIC segment only if section-based tables are empty
 
Comments suppressed due to low confidence (1)
symbolic-debuginfo/src/elf.rs:245
- Add unit tests to verify the new fallback behavior: parsing 
.dynsym/.dynstrsections in the absence of a PT_DYNAMIC segment, ensuring correct symbol resolution for debug-only ELF files. 
if obj.dynstrtab.len() == 0 {
If dynamic symbols cannot be parsed from the DYNAMIC segment, try to parse them from the section headers.
| 
           Some open questions: 
  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a fallback mechanism to locate and parse dynamic symbols using section headers when the DYNAMIC segment is missing, targeting debug information files produced by objcopy.
- Added fallback logic in elf.rs to iterate over section headers and parse .dynsym and .dynstr sections when obj.dynsyms is empty
 - Adjusted data parsing to support files without a DYNAMIC segment
 
| ctx | ||
| )); | ||
| 
               | 
          ||
| obj.dynstrtab = return_partial_on_err!(get_strtab(&obj.section_headers, shdr.sh_link as usize)); | 
    
      
    
      Copilot
AI
    
    
    
      May 22, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After successfully parsing the dynamic symbol table and string table, consider breaking out of the loop to prevent potential overwrites if multiple SHT_DYNSYM sections are present.
| obj.dynstrtab = return_partial_on_err!(get_strtab(&obj.section_headers, shdr.sh_link as usize)); | |
| obj.dynstrtab = return_partial_on_err!(get_strtab(&obj.section_headers, shdr.sh_link as usize)); | |
| break; | 
486baf3    to
    00204c9      
    Compare
  
    
Symbolic currently relies on DYNAMIC segment to locate and parse dynamic symbols.
This works for full executables but not for debug information extracted with
objcopy --only-keep-debugwhere we have added back dynamic symbol sections (.dynsym/.dynstr), because in those files, DYNAMIC segment is stripped.This PR adds the ability to use section headers to locate
.dynsymand.dynstrsections when DYNAMIC segment cannot be used.